/*
 * An XML document type.
 * Localname: library
 * Namespace: http://jugbrescia.dev.java.net/library
 * Java type: net.java.dev.jugbrescia.library.LibraryDocument
 *
 * Automatically generated - do not modify.
 */
package net.java.dev.jugbrescia.library.impl;
/**
 * A document containing one library(@http://jugbrescia.dev.java.net/library) element.
 *
 * This is a complex type.
 */
public class LibraryDocumentImpl extends org.apache.xmlbeans.impl.values.XmlComplexContentImpl implements net.java.dev.jugbrescia.library.LibraryDocument
{
    
    public LibraryDocumentImpl(org.apache.xmlbeans.SchemaType sType)
    {
        super(sType);
    }
    
    private static final javax.xml.namespace.QName LIBRARY$0 = 
        new javax.xml.namespace.QName("http://jugbrescia.dev.java.net/library", "library");
    
    
    /**
     * Gets the "library" element
     */
    public net.java.dev.jugbrescia.library.LibraryDocument.Library getLibrary()
    {
        synchronized (monitor())
        {
            check_orphaned();
            net.java.dev.jugbrescia.library.LibraryDocument.Library target = null;
            target = (net.java.dev.jugbrescia.library.LibraryDocument.Library)get_store().find_element_user(LIBRARY$0, 0);
            if (target == null)
            {
                return null;
            }
            return target;
        }
    }
    
    /**
     * Sets the "library" element
     */
    public void setLibrary(net.java.dev.jugbrescia.library.LibraryDocument.Library library)
    {
        synchronized (monitor())
        {
            check_orphaned();
            net.java.dev.jugbrescia.library.LibraryDocument.Library target = null;
            target = (net.java.dev.jugbrescia.library.LibraryDocument.Library)get_store().find_element_user(LIBRARY$0, 0);
            if (target == null)
            {
                target = (net.java.dev.jugbrescia.library.LibraryDocument.Library)get_store().add_element_user(LIBRARY$0);
            }
            target.set(library);
        }
    }
    
    /**
     * Appends and returns a new empty "library" element
     */
    public net.java.dev.jugbrescia.library.LibraryDocument.Library addNewLibrary()
    {
        synchronized (monitor())
        {
            check_orphaned();
            net.java.dev.jugbrescia.library.LibraryDocument.Library target = null;
            target = (net.java.dev.jugbrescia.library.LibraryDocument.Library)get_store().add_element_user(LIBRARY$0);
            return target;
        }
    }
    /**
     * An XML library(@http://jugbrescia.dev.java.net/library).
     *
     * This is a complex type.
     */
    public static class LibraryImpl extends org.apache.xmlbeans.impl.values.XmlComplexContentImpl implements net.java.dev.jugbrescia.library.LibraryDocument.Library
    {
        
        public LibraryImpl(org.apache.xmlbeans.SchemaType sType)
        {
            super(sType);
        }
        
        private static final javax.xml.namespace.QName BOOKS$0 = 
            new javax.xml.namespace.QName("http://jugbrescia.dev.java.net/library", "books");
        
        
        /**
         * Gets the "books" element
         */
        public net.java.dev.jugbrescia.library.LibraryDocument.Library.Books getBooks()
        {
            synchronized (monitor())
            {
                check_orphaned();
                net.java.dev.jugbrescia.library.LibraryDocument.Library.Books target = null;
                target = (net.java.dev.jugbrescia.library.LibraryDocument.Library.Books)get_store().find_element_user(BOOKS$0, 0);
                if (target == null)
                {
                    return null;
                }
                return target;
            }
        }
        
        /**
         * Sets the "books" element
         */
        public void setBooks(net.java.dev.jugbrescia.library.LibraryDocument.Library.Books books)
        {
            synchronized (monitor())
            {
                check_orphaned();
                net.java.dev.jugbrescia.library.LibraryDocument.Library.Books target = null;
                target = (net.java.dev.jugbrescia.library.LibraryDocument.Library.Books)get_store().find_element_user(BOOKS$0, 0);
                if (target == null)
                {
                    target = (net.java.dev.jugbrescia.library.LibraryDocument.Library.Books)get_store().add_element_user(BOOKS$0);
                }
                target.set(books);
            }
        }
        
        /**
         * Appends and returns a new empty "books" element
         */
        public net.java.dev.jugbrescia.library.LibraryDocument.Library.Books addNewBooks()
        {
            synchronized (monitor())
            {
                check_orphaned();
                net.java.dev.jugbrescia.library.LibraryDocument.Library.Books target = null;
                target = (net.java.dev.jugbrescia.library.LibraryDocument.Library.Books)get_store().add_element_user(BOOKS$0);
                return target;
            }
        }
        /**
         * An XML books(@http://jugbrescia.dev.java.net/library).
         *
         * This is a complex type.
         */
        public static class BooksImpl extends org.apache.xmlbeans.impl.values.XmlComplexContentImpl implements net.java.dev.jugbrescia.library.LibraryDocument.Library.Books
        {
            
            public BooksImpl(org.apache.xmlbeans.SchemaType sType)
            {
                super(sType);
            }
            
            private static final javax.xml.namespace.QName BOOK$0 = 
                new javax.xml.namespace.QName("http://jugbrescia.dev.java.net/library", "book");
            
            
            /**
             * Gets a List of "book" elements
             */
            public java.util.List<net.java.dev.jugbrescia.library.LibraryDocument.Library.Books.Book> getBookList()
            {
                final class BookList extends java.util.AbstractList<net.java.dev.jugbrescia.library.LibraryDocument.Library.Books.Book>
                {
                    public net.java.dev.jugbrescia.library.LibraryDocument.Library.Books.Book get(int i)
                        { return BooksImpl.this.getBookArray(i); }
                    
                    public net.java.dev.jugbrescia.library.LibraryDocument.Library.Books.Book set(int i, net.java.dev.jugbrescia.library.LibraryDocument.Library.Books.Book o)
                    {
                      net.java.dev.jugbrescia.library.LibraryDocument.Library.Books.Book old = BooksImpl.this.getBookArray(i);
                      BooksImpl.this.setBookArray(i, o);
                      return old;
                    }
                    
                    public void add(int i, net.java.dev.jugbrescia.library.LibraryDocument.Library.Books.Book o)
                        { BooksImpl.this.insertNewBook(i).set(o); }
                    
                    public net.java.dev.jugbrescia.library.LibraryDocument.Library.Books.Book remove(int i)
                    {
                      net.java.dev.jugbrescia.library.LibraryDocument.Library.Books.Book old = BooksImpl.this.getBookArray(i);
                      BooksImpl.this.removeBook(i);
                      return old;
                    }
                    
                    public int size()
                        { return BooksImpl.this.sizeOfBookArray(); }
                    
                }
                
                synchronized (monitor())
                {
                    check_orphaned();
                    return new BookList();
                }
            }
            
            /**
             * Gets array of all "book" elements
             */
            public net.java.dev.jugbrescia.library.LibraryDocument.Library.Books.Book[] getBookArray()
            {
                synchronized (monitor())
                {
                    check_orphaned();
                    java.util.List targetList = new java.util.ArrayList();
                    get_store().find_all_element_users(BOOK$0, targetList);
                    net.java.dev.jugbrescia.library.LibraryDocument.Library.Books.Book[] result = new net.java.dev.jugbrescia.library.LibraryDocument.Library.Books.Book[targetList.size()];
                    targetList.toArray(result);
                    return result;
                }
            }
            
            /**
             * Gets ith "book" element
             */
            public net.java.dev.jugbrescia.library.LibraryDocument.Library.Books.Book getBookArray(int i)
            {
                synchronized (monitor())
                {
                    check_orphaned();
                    net.java.dev.jugbrescia.library.LibraryDocument.Library.Books.Book target = null;
                    target = (net.java.dev.jugbrescia.library.LibraryDocument.Library.Books.Book)get_store().find_element_user(BOOK$0, i);
                    if (target == null)
                    {
                      throw new IndexOutOfBoundsException();
                    }
                    return target;
                }
            }
            
            /**
             * Returns number of "book" element
             */
            public int sizeOfBookArray()
            {
                synchronized (monitor())
                {
                    check_orphaned();
                    return get_store().count_elements(BOOK$0);
                }
            }
            
            /**
             * Sets array of all "book" element
             */
            public void setBookArray(net.java.dev.jugbrescia.library.LibraryDocument.Library.Books.Book[] bookArray)
            {
                synchronized (monitor())
                {
                    check_orphaned();
                    arraySetterHelper(bookArray, BOOK$0);
                }
            }
            
            /**
             * Sets ith "book" element
             */
            public void setBookArray(int i, net.java.dev.jugbrescia.library.LibraryDocument.Library.Books.Book book)
            {
                synchronized (monitor())
                {
                    check_orphaned();
                    net.java.dev.jugbrescia.library.LibraryDocument.Library.Books.Book target = null;
                    target = (net.java.dev.jugbrescia.library.LibraryDocument.Library.Books.Book)get_store().find_element_user(BOOK$0, i);
                    if (target == null)
                    {
                      throw new IndexOutOfBoundsException();
                    }
                    target.set(book);
                }
            }
            
            /**
             * Inserts and returns a new empty value (as xml) as the ith "book" element
             */
            public net.java.dev.jugbrescia.library.LibraryDocument.Library.Books.Book insertNewBook(int i)
            {
                synchronized (monitor())
                {
                    check_orphaned();
                    net.java.dev.jugbrescia.library.LibraryDocument.Library.Books.Book target = null;
                    target = (net.java.dev.jugbrescia.library.LibraryDocument.Library.Books.Book)get_store().insert_element_user(BOOK$0, i);
                    return target;
                }
            }
            
            /**
             * Appends and returns a new empty value (as xml) as the last "book" element
             */
            public net.java.dev.jugbrescia.library.LibraryDocument.Library.Books.Book addNewBook()
            {
                synchronized (monitor())
                {
                    check_orphaned();
                    net.java.dev.jugbrescia.library.LibraryDocument.Library.Books.Book target = null;
                    target = (net.java.dev.jugbrescia.library.LibraryDocument.Library.Books.Book)get_store().add_element_user(BOOK$0);
                    return target;
                }
            }
            
            /**
             * Removes the ith "book" element
             */
            public void removeBook(int i)
            {
                synchronized (monitor())
                {
                    check_orphaned();
                    get_store().remove_element(BOOK$0, i);
                }
            }
            /**
             * An XML book(@http://jugbrescia.dev.java.net/library).
             *
             * This is a complex type.
             */
            public static class BookImpl extends org.apache.xmlbeans.impl.values.XmlComplexContentImpl implements net.java.dev.jugbrescia.library.LibraryDocument.Library.Books.Book
            {
                
                public BookImpl(org.apache.xmlbeans.SchemaType sType)
                {
                    super(sType);
                }
                
                private static final javax.xml.namespace.QName AUTHORS$0 = 
                    new javax.xml.namespace.QName("http://jugbrescia.dev.java.net/library", "authors");
                private static final javax.xml.namespace.QName TITLE$2 = 
                    new javax.xml.namespace.QName("", "title");
                
                
                /**
                 * Gets the "authors" element
                 */
                public net.java.dev.jugbrescia.library.LibraryDocument.Library.Books.Book.Authors getAuthors()
                {
                    synchronized (monitor())
                    {
                      check_orphaned();
                      net.java.dev.jugbrescia.library.LibraryDocument.Library.Books.Book.Authors target = null;
                      target = (net.java.dev.jugbrescia.library.LibraryDocument.Library.Books.Book.Authors)get_store().find_element_user(AUTHORS$0, 0);
                      if (target == null)
                      {
                        return null;
                      }
                      return target;
                    }
                }
                
                /**
                 * Sets the "authors" element
                 */
                public void setAuthors(net.java.dev.jugbrescia.library.LibraryDocument.Library.Books.Book.Authors authors)
                {
                    synchronized (monitor())
                    {
                      check_orphaned();
                      net.java.dev.jugbrescia.library.LibraryDocument.Library.Books.Book.Authors target = null;
                      target = (net.java.dev.jugbrescia.library.LibraryDocument.Library.Books.Book.Authors)get_store().find_element_user(AUTHORS$0, 0);
                      if (target == null)
                      {
                        target = (net.java.dev.jugbrescia.library.LibraryDocument.Library.Books.Book.Authors)get_store().add_element_user(AUTHORS$0);
                      }
                      target.set(authors);
                    }
                }
                
                /**
                 * Appends and returns a new empty "authors" element
                 */
                public net.java.dev.jugbrescia.library.LibraryDocument.Library.Books.Book.Authors addNewAuthors()
                {
                    synchronized (monitor())
                    {
                      check_orphaned();
                      net.java.dev.jugbrescia.library.LibraryDocument.Library.Books.Book.Authors target = null;
                      target = (net.java.dev.jugbrescia.library.LibraryDocument.Library.Books.Book.Authors)get_store().add_element_user(AUTHORS$0);
                      return target;
                    }
                }
                
                /**
                 * Gets the "title" attribute
                 */
                public java.lang.String getTitle()
                {
                    synchronized (monitor())
                    {
                      check_orphaned();
                      org.apache.xmlbeans.SimpleValue target = null;
                      target = (org.apache.xmlbeans.SimpleValue)get_store().find_attribute_user(TITLE$2);
                      if (target == null)
                      {
                        return null;
                      }
                      return target.getStringValue();
                    }
                }
                
                /**
                 * Gets (as xml) the "title" attribute
                 */
                public org.apache.xmlbeans.XmlString xgetTitle()
                {
                    synchronized (monitor())
                    {
                      check_orphaned();
                      org.apache.xmlbeans.XmlString target = null;
                      target = (org.apache.xmlbeans.XmlString)get_store().find_attribute_user(TITLE$2);
                      return target;
                    }
                }
                
                /**
                 * True if has "title" attribute
                 */
                public boolean isSetTitle()
                {
                    synchronized (monitor())
                    {
                      check_orphaned();
                      return get_store().find_attribute_user(TITLE$2) != null;
                    }
                }
                
                /**
                 * Sets the "title" attribute
                 */
                public void setTitle(java.lang.String title)
                {
                    synchronized (monitor())
                    {
                      check_orphaned();
                      org.apache.xmlbeans.SimpleValue target = null;
                      target = (org.apache.xmlbeans.SimpleValue)get_store().find_attribute_user(TITLE$2);
                      if (target == null)
                      {
                        target = (org.apache.xmlbeans.SimpleValue)get_store().add_attribute_user(TITLE$2);
                      }
                      target.setStringValue(title);
                    }
                }
                
                /**
                 * Sets (as xml) the "title" attribute
                 */
                public void xsetTitle(org.apache.xmlbeans.XmlString title)
                {
                    synchronized (monitor())
                    {
                      check_orphaned();
                      org.apache.xmlbeans.XmlString target = null;
                      target = (org.apache.xmlbeans.XmlString)get_store().find_attribute_user(TITLE$2);
                      if (target == null)
                      {
                        target = (org.apache.xmlbeans.XmlString)get_store().add_attribute_user(TITLE$2);
                      }
                      target.set(title);
                    }
                }
                
                /**
                 * Unsets the "title" attribute
                 */
                public void unsetTitle()
                {
                    synchronized (monitor())
                    {
                      check_orphaned();
                      get_store().remove_attribute(TITLE$2);
                    }
                }
                /**
                 * An XML authors(@http://jugbrescia.dev.java.net/library).
                 *
                 * This is a complex type.
                 */
                public static class AuthorsImpl extends org.apache.xmlbeans.impl.values.XmlComplexContentImpl implements net.java.dev.jugbrescia.library.LibraryDocument.Library.Books.Book.Authors
                {
                    
                    public AuthorsImpl(org.apache.xmlbeans.SchemaType sType)
                    {
                      super(sType);
                    }
                    
                    private static final javax.xml.namespace.QName AUTHOR$0 = 
                      new javax.xml.namespace.QName("http://jugbrescia.dev.java.net/library", "author");
                    
                    
                    /**
                     * Gets a List of "author" elements
                     */
                    public java.util.List<net.java.dev.jugbrescia.library.LibraryDocument.Library.Books.Book.Authors.Author> getAuthorList()
                    {
                      final class AuthorList extends java.util.AbstractList<net.java.dev.jugbrescia.library.LibraryDocument.Library.Books.Book.Authors.Author>
                      {
                        public net.java.dev.jugbrescia.library.LibraryDocument.Library.Books.Book.Authors.Author get(int i)
                            { return AuthorsImpl.this.getAuthorArray(i); }
                        
                        public net.java.dev.jugbrescia.library.LibraryDocument.Library.Books.Book.Authors.Author set(int i, net.java.dev.jugbrescia.library.LibraryDocument.Library.Books.Book.Authors.Author o)
                        {
                          net.java.dev.jugbrescia.library.LibraryDocument.Library.Books.Book.Authors.Author old = AuthorsImpl.this.getAuthorArray(i);
                          AuthorsImpl.this.setAuthorArray(i, o);
                          return old;
                        }
                        
                        public void add(int i, net.java.dev.jugbrescia.library.LibraryDocument.Library.Books.Book.Authors.Author o)
                            { AuthorsImpl.this.insertNewAuthor(i).set(o); }
                        
                        public net.java.dev.jugbrescia.library.LibraryDocument.Library.Books.Book.Authors.Author remove(int i)
                        {
                          net.java.dev.jugbrescia.library.LibraryDocument.Library.Books.Book.Authors.Author old = AuthorsImpl.this.getAuthorArray(i);
                          AuthorsImpl.this.removeAuthor(i);
                          return old;
                        }
                        
                        public int size()
                            { return AuthorsImpl.this.sizeOfAuthorArray(); }
                        
                      }
                      
                      synchronized (monitor())
                      {
                        check_orphaned();
                        return new AuthorList();
                      }
                    }
                    
                    /**
                     * Gets array of all "author" elements
                     */
                    public net.java.dev.jugbrescia.library.LibraryDocument.Library.Books.Book.Authors.Author[] getAuthorArray()
                    {
                      synchronized (monitor())
                      {
                        check_orphaned();
                        java.util.List targetList = new java.util.ArrayList();
                        get_store().find_all_element_users(AUTHOR$0, targetList);
                        net.java.dev.jugbrescia.library.LibraryDocument.Library.Books.Book.Authors.Author[] result = new net.java.dev.jugbrescia.library.LibraryDocument.Library.Books.Book.Authors.Author[targetList.size()];
                        targetList.toArray(result);
                        return result;
                      }
                    }
                    
                    /**
                     * Gets ith "author" element
                     */
                    public net.java.dev.jugbrescia.library.LibraryDocument.Library.Books.Book.Authors.Author getAuthorArray(int i)
                    {
                      synchronized (monitor())
                      {
                        check_orphaned();
                        net.java.dev.jugbrescia.library.LibraryDocument.Library.Books.Book.Authors.Author target = null;
                        target = (net.java.dev.jugbrescia.library.LibraryDocument.Library.Books.Book.Authors.Author)get_store().find_element_user(AUTHOR$0, i);
                        if (target == null)
                        {
                          throw new IndexOutOfBoundsException();
                        }
                        return target;
                      }
                    }
                    
                    /**
                     * Returns number of "author" element
                     */
                    public int sizeOfAuthorArray()
                    {
                      synchronized (monitor())
                      {
                        check_orphaned();
                        return get_store().count_elements(AUTHOR$0);
                      }
                    }
                    
                    /**
                     * Sets array of all "author" element
                     */
                    public void setAuthorArray(net.java.dev.jugbrescia.library.LibraryDocument.Library.Books.Book.Authors.Author[] authorArray)
                    {
                      synchronized (monitor())
                      {
                        check_orphaned();
                        arraySetterHelper(authorArray, AUTHOR$0);
                      }
                    }
                    
                    /**
                     * Sets ith "author" element
                     */
                    public void setAuthorArray(int i, net.java.dev.jugbrescia.library.LibraryDocument.Library.Books.Book.Authors.Author author)
                    {
                      synchronized (monitor())
                      {
                        check_orphaned();
                        net.java.dev.jugbrescia.library.LibraryDocument.Library.Books.Book.Authors.Author target = null;
                        target = (net.java.dev.jugbrescia.library.LibraryDocument.Library.Books.Book.Authors.Author)get_store().find_element_user(AUTHOR$0, i);
                        if (target == null)
                        {
                          throw new IndexOutOfBoundsException();
                        }
                        target.set(author);
                      }
                    }
                    
                    /**
                     * Inserts and returns a new empty value (as xml) as the ith "author" element
                     */
                    public net.java.dev.jugbrescia.library.LibraryDocument.Library.Books.Book.Authors.Author insertNewAuthor(int i)
                    {
                      synchronized (monitor())
                      {
                        check_orphaned();
                        net.java.dev.jugbrescia.library.LibraryDocument.Library.Books.Book.Authors.Author target = null;
                        target = (net.java.dev.jugbrescia.library.LibraryDocument.Library.Books.Book.Authors.Author)get_store().insert_element_user(AUTHOR$0, i);
                        return target;
                      }
                    }
                    
                    /**
                     * Appends and returns a new empty value (as xml) as the last "author" element
                     */
                    public net.java.dev.jugbrescia.library.LibraryDocument.Library.Books.Book.Authors.Author addNewAuthor()
                    {
                      synchronized (monitor())
                      {
                        check_orphaned();
                        net.java.dev.jugbrescia.library.LibraryDocument.Library.Books.Book.Authors.Author target = null;
                        target = (net.java.dev.jugbrescia.library.LibraryDocument.Library.Books.Book.Authors.Author)get_store().add_element_user(AUTHOR$0);
                        return target;
                      }
                    }
                    
                    /**
                     * Removes the ith "author" element
                     */
                    public void removeAuthor(int i)
                    {
                      synchronized (monitor())
                      {
                        check_orphaned();
                        get_store().remove_element(AUTHOR$0, i);
                      }
                    }
                    /**
                     * An XML author(@http://jugbrescia.dev.java.net/library).
                     *
                     * This is a complex type.
                     */
                    public static class AuthorImpl extends org.apache.xmlbeans.impl.values.XmlComplexContentImpl implements net.java.dev.jugbrescia.library.LibraryDocument.Library.Books.Book.Authors.Author
                    {
                      
                      public AuthorImpl(org.apache.xmlbeans.SchemaType sType)
                      {
                        super(sType);
                      }
                      
                      private static final javax.xml.namespace.QName NAME$0 = 
                        new javax.xml.namespace.QName("", "name");
                      
                      
                      /**
                       * Gets the "name" attribute
                       */
                      public java.lang.String getName()
                      {
                        synchronized (monitor())
                        {
                          check_orphaned();
                          org.apache.xmlbeans.SimpleValue target = null;
                          target = (org.apache.xmlbeans.SimpleValue)get_store().find_attribute_user(NAME$0);
                          if (target == null)
                          {
                            return null;
                          }
                          return target.getStringValue();
                        }
                      }
                      
                      /**
                       * Gets (as xml) the "name" attribute
                       */
                      public org.apache.xmlbeans.XmlString xgetName()
                      {
                        synchronized (monitor())
                        {
                          check_orphaned();
                          org.apache.xmlbeans.XmlString target = null;
                          target = (org.apache.xmlbeans.XmlString)get_store().find_attribute_user(NAME$0);
                          return target;
                        }
                      }
                      
                      /**
                       * True if has "name" attribute
                       */
                      public boolean isSetName()
                      {
                        synchronized (monitor())
                        {
                          check_orphaned();
                          return get_store().find_attribute_user(NAME$0) != null;
                        }
                      }
                      
                      /**
                       * Sets the "name" attribute
                       */
                      public void setName(java.lang.String name)
                      {
                        synchronized (monitor())
                        {
                          check_orphaned();
                          org.apache.xmlbeans.SimpleValue target = null;
                          target = (org.apache.xmlbeans.SimpleValue)get_store().find_attribute_user(NAME$0);
                          if (target == null)
                          {
                            target = (org.apache.xmlbeans.SimpleValue)get_store().add_attribute_user(NAME$0);
                          }
                          target.setStringValue(name);
                        }
                      }
                      
                      /**
                       * Sets (as xml) the "name" attribute
                       */
                      public void xsetName(org.apache.xmlbeans.XmlString name)
                      {
                        synchronized (monitor())
                        {
                          check_orphaned();
                          org.apache.xmlbeans.XmlString target = null;
                          target = (org.apache.xmlbeans.XmlString)get_store().find_attribute_user(NAME$0);
                          if (target == null)
                          {
                            target = (org.apache.xmlbeans.XmlString)get_store().add_attribute_user(NAME$0);
                          }
                          target.set(name);
                        }
                      }
                      
                      /**
                       * Unsets the "name" attribute
                       */
                      public void unsetName()
                      {
                        synchronized (monitor())
                        {
                          check_orphaned();
                          get_store().remove_attribute(NAME$0);
                        }
                      }
                    }
                }
            }
        }
    }
}
